import React, { Component } from 'react'
import { Grid } from 'antd-mobile'
import axios from 'axios'
import '../../assets/css/home/k-subject.less'

export default class Ksubject extends Component {
  state = {
    data: []
  }
  render() {
    return (
      <div className="k-subject">
        <Grid columns={4} style={{'--gap-vertical':'16px'}}>
          {this.state.data.map((e, i) => {
            return (
              <Grid.Item key={i}>
                <img src={e.icon} alt="图片加载失败" />
                <div className="text">{e.text}</div>
              </Grid.Item>
            )
          })}
        </Grid>
      </div>
    )
  }
  componentDidMount() {
    axios.get('/data/subject.json').then((res) => {
      this.setState({
        data: res.data
      })
    })
  }
}
